﻿//===================================================================
// 西交通开发框架-XCI.Parent 2019 版权所有     
//===================================================================
using System;
using System.ComponentModel.DataAnnotations;
using XCI.Data.Entity;

namespace XCI.Sys.Model
{
    /// <summary>
    /// 系统模块
    /// </summary>
    [Table("系统模块")]
    public class SysModule
    {
        /// <summary>
        /// 模块主键
        /// </summary>
        [Primary]
        [Column("模块主键", false)]
        public string Id { get; set; }

        /// <summary>
        /// 模块上级主键
        /// </summary>
        [Parent]
        [Column("模块上级主键")]
        public string ParentId { get; set; }

        /// <summary>
        /// 模块名称
        /// </summary>
        [Column("模块名称")]
        [Required(ErrorMessage = "请输入模块名称")]
        [StringLength(100, ErrorMessage = "模块名称不能超过100个字符")]
        public string Name { get; set; }

        /// <summary>
        /// 模块编码
        /// </summary>
        [Column("模块编码")]
        [Required(ErrorMessage = "请输入模块编码")]
        [StringLength(100, ErrorMessage = "模块编码不能超过100个字符")]
        public string Code { get; set; }

        /// <summary>
        /// 功能权限
        /// </summary>
        [Column("功能权限")]
        public string NameCode => $"{Name}({Code})";

        /// <summary>
        /// 模块名称简拼
        /// </summary>
        [Column("模块名称简拼", false)]
        [StringLength(100, ErrorMessage = "模块名称简拼不能超过100个字符")]
        public string Spell { get; set; }

        /// <summary>
        /// 模块参数
        /// </summary>
        [Column("模块参数")]
        [StringLength(1000, ErrorMessage = "模块参数不能超过1000个字符")]
        public string ParamData { get; set; }

        /// <summary>
        /// Web地址
        /// </summary>
        [Column("Web地址")]
        [StringLength(200, ErrorMessage = "Web地址不能超过200个字符")]
        public string WebUrl { get; set; }

        /// <summary>
        /// Web图标
        /// </summary>
        [Column("Web图标")]
        [StringLength(100, ErrorMessage = "Web图标不能超过100个字符")]
        public string WebCls { get; set; }

        /// <summary>
        /// WinFrom窗口类
        /// </summary>
        [Column("WinFrom窗口类")]
        [StringLength(200, ErrorMessage = "WinFrom窗口类不能超过200个字符")]
        public string WinProvider { get; set; }

        /// <summary>
        /// WinFrom大图标
        /// </summary>
        [Column("WinFrom大图标")]
        [StringLength(100, ErrorMessage = "WinFrom大图标不能超过100个字符")]
        public string WinLargeIcon { get; set; }

        /// <summary>
        /// WinFrom小图标
        /// </summary>
        [Column("WinFrom小图标")]
        [StringLength(100, ErrorMessage = "WinFrom小图标不能超过100个字符")]
        public string WinSmallIcon { get; set; }

        /// <summary>
        /// 是否Web菜单
        /// </summary>
        [Column("是否Web菜单")]
        public bool? WebFlag { get; set; }

        /// <summary>
        /// 是否WinForm菜单
        /// </summary>
        [Column("是否WinForm菜单")]
        public bool? WinFlag { get; set; }

        /// <summary>
        /// 是否展开
        /// </summary>
        [Column("是否展开")]
        public bool? ExpandFlag { get; set; }

        /// <summary>
        /// 是否公开
        /// </summary>
        [Column("是否公开")]
        public bool? PublicFlag { get; set; }

        /// <summary>
        /// 是否菜单
        /// </summary>
        [Column("是否菜单")]
        public bool? MenuFlag { get; set; }

        /// <summary>
        /// 是否权限
        /// </summary>
        [Column("是否权限")]
        public bool PermissionFlag => !MenuFlag.HasValue || !MenuFlag.Value;

        /// <summary>
        /// 是否显示为对话框
        /// </summary>
        [Column("是否显示为对话框")]
        public bool? DialogFlag { get; set; }

        /// <summary>
        /// 是否预加载
        /// </summary>
        [Column("是否预加载")]
        public bool? PreloadingFlag { get; set; }

        /// <summary>
        /// 是否矢量图
        /// </summary>
        [Column("是否矢量图")]
        public bool? VectorGraphFlag { get; set; }

        /// <summary>
        /// 排序路径
        /// </summary>
        [Path]
        [Column("排序路径")]
        [StringLength(100, ErrorMessage = "排序路径不能超过100个字符")]
        public string Path { get; set; }

        /// <summary>
        /// 状态(0:禁用;1:启用)
        /// </summary>
        [Column("状态")]
        public bool? Status { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        [Column("备注")]
        [StringLength(500, ErrorMessage = "备注不能超过500个字符")]
        public string Remark { get; set; }

        /// <summary>
        /// 复制对象
        /// </summary>
        public SysModule Clone()
        {
            return (SysModule)MemberwiseClone();
        }
    }
}
